import pymysql

kwargs = {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "123456",
    "database": "stu",
    "charset": "utf8"
}
db = pymysql.connect(**kwargs)
cur = db.cursor()
sql = "select * from hobby where id<%s;"
cur.executemany(sql,[7])
# one =cur.fetchone()
# print("一条记录:",one)
# many = cur.fetchmany(3)
# print("3条记录:",many)
all=cur.fetchall()
print("全部记录:",all)

# db.commit()
cur.close()
db.close()